package com.itheima.springboot.config;

import com.itheima.springboot.conditional.ConditionOnClass;
import com.itheima.springboot.domain.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UserConfig {

    //扫描并创建user的bean
    @Bean
    //前提条件要满足Condutional_Class内的方法，返回false创建user的bean不存在则不创建
    @ConditionOnClass("redis.clients.jedis.Jedis")
    public User user(){

        return new User();
    }


    @Bean
    //前提条件要在properties中满足key和value相同，才会创建user
    @ConditionalOnProperty(name = "itheima",havingValue = "itcast")
    public User users(){

        return new User();
    }
}
